package com.wang.test;

import java.util.Date;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AnalogClock;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.TimePicker;

import com.wang.ioc.BaseV4FragmentActivity;
import com.wang.ioc.annotation.ViewComponent;
import com.wang.ioc.annotation.ViewComponent.KeyboardState;
import com.wang.ioc.annotation.ViewComponent.VisibilityState;

@SuppressLint("NewApi")
public class MainActivity extends BaseV4FragmentActivity {
	private View LinearLayout1;
	private View LinearLayout2;
	@ViewComponent(name="textView2",defaultTextValueResId=R.string.app_name)
	private TextView myTextView;
	@ViewComponent(imageResource=R.drawable.fb_carnotice_1)
	private ImageView imageView1;
	@ViewComponent(defaultTextValue="默认键盘是打开还是没打开呢",defaultKeyboardState=KeyboardState.CLOSE,parentViewId=R.id.LinearLayout2)
	private EditText editText1;
	@ViewComponent(defaultVisibility=VisibilityState.KEEP)
	private TimePicker timePicker1;
	@ViewComponent(defaultVisibility=VisibilityState.KEEP)
	private AnalogClock analogClock1;
	@ViewComponent(clickEventSource=true,defaultTextValue="按钮1",defaultVisibility=VisibilityState.KEEP)
	private Button button1;
	@ViewComponent(clickEventSource=true,defaultVisibility=VisibilityState.KEEP)
	private Button button2;
	@ViewComponent(clickEventSource=true,id=R.id.checkBox1)	
	private CheckBox checkBox1_;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
//		myTextView.setText("哈哈哈看起来这个才是真的");
	}
	
	@Override
	public void onClick(View v) {
		if(v==button1){
			LinearLayout2.setVisibility(View.GONE);
			TestV4Fragment f=new TestV4Fragment();
			FragmentManager fm = this.getSupportFragmentManager();
			FragmentTransaction ft = fm.beginTransaction();
			ft.add(LinearLayout1.getId(), f);
			ft.commitAllowingStateLoss();
		}
		if(v==button2){
			Intent intent=new Intent(this, SecondActivity.class);
			System.out.println("@@ 跳转前 "+new Date().getTime());
			startActivity(intent);
			System.out.println("@@ 跳转后 "+new Date().getTime());
		}
		if(v==checkBox1_){
			myTextView.setText(new Date().toLocaleString());
		}
		
	}
}
